<template>
  <el-row>
    <el-col :span="24"
            style="display:flex;flex-wrap:wrap;flex-direction:row">
      <span v-for="(item,i) in verArr"
            :key="i">
        <el-button class="button-style"
                   @click="lookMode(item)"> {{item.versionName}}</el-button>
      </span>
    </el-col>
  </el-row>
</template>
<script>
import { ModelManageApi } from '@/services/WorkCenter'
export default {
  props: {
    callBackVer: Function,
    todosVer: String
  },
  data () {
    return {
      verArr: []
    }
  },
  methods: {
    lookMode (val) { //查看模型
      this.callBackVer(val)
    },
    getVerList () {//获取版本号
      ModelManageApi.getVerList({
        params: {
          modelId: this.todosVer
        }
      }).then((res) => {
        this.verArr = res.data;
        // console.log('res=', res)
      }).catch((error) => {
        console.log(error)
      })
    },
  },
  watch: {
    todosVer (n, o) {
      if (n != '') {
        this.getVerList()
      }
      // console.log('w-todosVer=', n)
    }
  },
  created () {
    if (this.todosVer != '') {
      this.getVerList()
    }
    // console.log('c-todosVer=', this.todosVer)
  }
}
</script>

<style lang="scss" scoped>
.button-style {
  width: 91px;
  text-align: center;
  padding: 0px;
  height: 40px;
  bottom: 20px;
  margin: 0px 12px 20px 0px;
}
</style>